package adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.administrator.ci_edit.R;

import java.util.List;

import model.Community;

/**
 * Created by mary on 2017/7/15.
 */

public class FCAdapter extends ArrayAdapter<Community> {
    private int resourceId;

    public FCAdapter(Context context, int textViewResourceId, List<Community> objects) {
        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Community Info = getItem(position);
        //View view = LayoutInflater.from(getContext()).inflate(resourceId,null);
        //用新的方式，提升ListView的运行效率
        View view;
        if (convertView == null) {
            view = LayoutInflater.from(getContext()).inflate(resourceId, null);
        } else {
            view = convertView;
        }
        TextView username = (TextView) view.findViewById(R.id.username);
        TextView poem = (TextView) view.findViewById(R.id.poem);
        TextView time = (TextView) view.findViewById(R.id.time);
        TextView tune = (TextView) view.findViewById(R.id.tune);
//        Name.setText(Info.getName());
//        Content.setText(Info.getContent());
        return view;
        //return super.getView(position, convertView, parent);
    }
}
